
#include "Can_Array.h"


/////////////////////////////////////
////          Struct part        ////
/////////////////////////////////////
template<class NodeT>
Can_Array_Conf<NodeT>::Can_Array_Conf() : Object_Base_Conf()
{
}

/////////////////////////////////////
////          Class part         ////
/////////////////////////////////////

/**
 *
 */
template<class NodeT>
NodeT** Can_Array<NodeT>::getAllData()
{
    return m_arData;
}

/**
 *
 */
template<class NodeT>
int Can_Array<NodeT>::putOne(NodeT* a_item)
{
    m_arData[m_sCan_Array_Conf->position] = a_item;
    m_sCan_Array_Conf->position++;
    m_sCan_Array_Conf->size++;
}

/**
 *
 */
template<class NodeT>
int Can_Array<NodeT>::putSome(NodeT** a_items, int a_itemSize)
{
    // use for check if the put-oprate is finish
    int _checkposition = m_sCan_Array_Conf->position;
    // for return
    int _result = 0;
    
    int _itemSize = 0;
    if(a_itemSize <= 0)
    {
        _itemSize = sizeof(*a_items) / sizeof(NodeT*);
    }
    else
    {
        _itemSize = a_itemSize;
    }
    
    int i = 0;
    for(i = 0; i < _itemSize; i++, m_sCan_Array_Conf->position++)
    {
        m_arData[m_sCan_Array_Conf->position] = a_items[i];
    }
    // check if add success
    _result  = (_checkposition + _itemSize) - m_sCan_Array_Conf->position;
    // change size
    m_sCan_Array_Conf->size = m_sCan_Array_Conf->size + _itemSize;
    
    return _result;
}

/**
 *
 */
template<class NodeT>
Can_Array<NodeT>::Can_Array() : Object_Base()
{
    m_sCan_Array_Conf = new Can_Array_Conf<NodeT>();
    // init position
    m_sCan_Array_Conf->position = 0;
    // data list size
    m_sCan_Array_Conf->size = 10;
}








